package com.liuanbang.saro.sarodemo.ui.popup;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;

import com.liuanbang.saro.sarodemo.R;
import com.liuanbang.saro.sarodemo.adapter.ArrayWheelAdapter;
import com.liuanbang.saro.sarodemo.base.AbstractDialog;
import com.liuanbang.saro.sarodemo.view.WheelView;

import java.util.ArrayList;

/**
 * Created by 刘安邦 on 2016/9/10.
 * Email:liuanbang@aliyun.com
 * 描述:   滚轮选择器    2016/9/10
 * 修改:       2016/9/10
 */
public class CommonChoosePopupWindow extends AbstractDialog {
    private View rootView = null;

    /**
     * Instantiates a new Confirm popup.
     *
     * @param activity the activity
     */
    public CommonChoosePopupWindow(Activity activity, ArrayList<String> list, final OnDialogItemSelectListener onDialogItemSelectListener) {
        super(activity);
        rootView = ((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_common_choose_popupwindow, null);
        WheelView wheelView = (WheelView) rootView.findViewById(R.id.wheelView_common_choose_popupwindow);
        wheelView.setCyclic(false);
        wheelView.setAdapter(new ArrayWheelAdapter<String>(list));
        wheelView.setOnItemSelectedListener(new WheelView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(int index) {

            }
        });
        //取消
        rootView.findViewById(R.id.text_common_choose_popupwindow_cancle).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                dismiss();
            }
        });
        //完成
        rootView.findViewById(R.id.text_common_choose_popupwindow_select).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                onDialogItemSelectListener.onDialogItemSelect(1, "", "");
                dismiss();
            }
        });
    }

    @NonNull
    @Override
    protected View makeCenterView() {
        return rootView;
    }
}
